<%@ page import="com.zywl.utils.utils.IPUtil" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@include file="../base/base.jspf" %>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/style.css"/>
<div class="layui-form" style="padding: 47px 0 0 70px;">
    <input type="hidden" name="memberId" value="${member.memberId}"/>
    <input type="hidden" name="memberUrl" value="${member.memberUrl}"/>
    <input type="hidden" name="memberStt" value="${member.memberStt}"/>

    <div class="layui-col-xs6">
        <div class="layui-form-item">
            <label class="layui-form-label">合作伙伴名称</label>
            <div class="layui-input-inline">
                <input type="text" value="${member.memberName}" name="memberName" lay-verify="required"
                       placeholder="请输入合作伙伴名称"
                       class="layui-input"/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">合作伙伴状态</label>
            <div class="layui-input-block">
                <select name="memberStt" lay-verify="required">
                    <c:if test="${member.memberStt=='0'}">
                        <option value="0">合作中</option>
                        <option value="1">未合作</option>
                    </c:if>
                    <c:if test="${member.memberStt=='1'}">
                        <option value="1">未合作</option>
                        <option value="0">合作中</option>
                    </c:if>
                    <c:if test="${member.memberStt==null}">
                        <option value=""></option>
                        <option value="0">合作中</option>
                        <option value="1">未合作</option>
                    </c:if>

                </select>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">合作伙伴图片</label>
            <div class="layui-col-xs6">
                <div class="text-center" id="clickToUploadHead">
                    <a href="javascript:void(0);" class="upimg-a">
                        <img style="height: 250px; width: 250px;" src="${ctx}${member.memberUrl}"
                             id="member-memberSubmitPage-memberHead"
                             class="thumbnail"
                             onerror="javascript:this.src='${ctx}/static/images/pic-default.jpg';">
                        <div class="upimg-shade">
                    <span style="margin-left: 20%;">
                      点击上传
                    </span>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit id="member-front-submit" lay-filter="member-front-submit" value="确认"/>
    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: "${ctx}/static/framework/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use(["index", "form","upload","laydate"], function () {
        var upload = layui.upload, form = layui.form,laydate = layui.laydate;

        upload.render({
            elem: "#clickToUploadHead",
            url: "${ctx}/member/uploadFile",
            multiple: true,
            accept: "images",
            acceptMime: "image/*",
            size: 2048,//限制文件大小，单位 KB
            type: "post",
            done: function (result) {
                $("#member-memberSubmitPage-memberHead").attr("src", "${ctx}" + result.path);

                $("input[name='memberUrl']").val(result.path);
            }
        });


        form.on("submit(member-front-submit)", function (data) {
            $("#member-front-submit").attr("disabled", true);
            tip_index = load();
            var field = data.field; //获取提交的字段
            $.ajax({
                async: true,
                url: "${ctx}/member/memberSubmit",
                type: "post",
                dataType: "json",
                data: field,
                success: function (data) {
                    layer.close(tip_index);
                    if (data.result) {
                        parentTableReload("member-memberList-page");
                        successUp(data.info);
                        closeDialog();
                    } else {
                        $("#member-front-submit").attr("disabled",false);
                        error(data.info);
                    }
                }
            });
        });
    });
</script>
